<template>
  <div>
    <van-form @submit="onSubmit">
      <slot name="lab"></slot>
      <van-field
        :type="item.type"
        @input="changeInput(form)"
        v-for="item of formList"
        :key="item.model"
        v-model="form[item.model]"
        :name="item.model"
        :label="item.label"
        :placeholder="'请输入' + item.name"
      />
      <slot name="code"></slot>
      <slot name="tip"></slot>
      <slot name="butLogin"></slot>
    </van-form>
  </div>
</template>

<script>
export default {
  name: 'Form',
  props: {
    form: Object,
    formList: Array
  },
  data() {
    return {}
  },
  methods: {
    onSubmit(sub) {
      this.$emit('formLogin', sub)
    },
    changeInput(res) {
      // 监听input的值
      this.$emit('formInput', res)
    }
  },
  watch: {}
}
</script>
<style lang="scss" scoped></style>
